/*********************************************************
*  OCTest Project - A Test C Framework for testing OpenCPU
*  Copyright (c) 2022 China Mobile IOT.
*  created by sushundi 2022-01-10
********************************************************/

#ifndef OCTEST_H
#define OCTEST_H

#include "octest_internals.h"

#define OCTEST_FUNC_EXPECT_TRUE(actual, calledFuncName)                                  OCTestExpectEqualNumber(1, (OCTEST_INT32)(actual), __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_BOOL)
#define OCTEST_FUNC_EXPECT_FALSE(actual, calledFuncName)                                 OCTestExpectEqualNumber(0, (OCTEST_INT32)(actual), __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_BOOL)
#define OCTEST_FUNC_EXPECT_NOT_NULL(actual, calledFuncName)                              OCTestExpectEqualNumber(1, (OCTEST_INT32)(actual), __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_NULL)
#define OCTEST_FUNC_EXPECT_NULL(actual, calledFuncName)                                  OCTestExpectEqualNumber(0, (OCTEST_INT32)(actual), __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_NULL)
#define OCTEST_FUNC_EXPECT_EQUAL_INT32(expected, actual, calledFuncName)                 OCTestExpectEqualNumber((OCTEST_INT32)(expected), (OCTEST_INT32)(actual), __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_FUNC_EXPECT_EQUAL_UINT32(expected, actual, calledFuncName)                OCTestExpectEqualNumber((OCTEST_UINT32)(expected), (OCTEST_UINT32)(actual), __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_FUNC_EXPECT_NOT_EQUAL_INT32(threshold, actual, calledFuncName)            OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_NOT_EQUAL, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_FUNC_EXPECT_NOT_EQUAL_UINT32(threshold, actual, calledFuncName)           OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_NOT_EQUAL, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_FUNC_EXPECT_GREATER_THAN_INT32(threshold, actual, calledFuncName)         OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_GREATER_THAN, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_FUNC_EXPECT_GREATER_THAN_UINT32(threshold, actual, calledFuncName)        OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_GREATER_THAN, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_FUNC_EXPECT_LESS_THAN_INT32(threshold, actual, calledFuncName)            OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_SMALLER_THAN, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_FUNC_EXPECT_LESS_THAN_UINT32(threshold, actual, calledFuncName)           OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_SMALLER_THAN, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_FUNC_EXPECT_GREATER_OR_EQUAL_INT32(threshold, actual, calledFuncName)     OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_GREATER_OR_EQUAL, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_FUNC_EXPECT_GREATER_OR_EQUAL_UINT32(threshold, actual, calledFuncName)    OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_GREATER_OR_EQUAL, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_FUNC_EXPECT_LESS_OR_EQUAL_INT32(threshold, actual, calledFuncName)        OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_SMALLER_OR_EQUAL, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_FUNC_EXPECT_LESS_OR_EQUAL_UINT32(threshold, actual, calledFuncName)       OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_SMALLER_OR_EQUAL, __FILE__, (#calledFuncName), OCTEST_MSG_FUNC_CALL, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)

#define OCTEST_FUNC_RETURN_UINT32(actual, calledFuncName)                                OCTestExecuteFucWithReturn((void *)(actual), __FILE__, (#calledFuncName), __LINE__, OCTEST_DISPLAY_STYLE_UINT32, OCTEST_FUC_RETURN_VALUE)
#define OCTEST_FUNC_RETURN_INT32(actual, calledFuncName)                                 OCTestExecuteFucWithReturn((void *)(actual), __FILE__, (#calledFuncName), __LINE__, OCTEST_DISPLAY_STYLE_INT32, OCTEST_FUC_RETURN_VALUE)
#define OCTEST_FUNC_RETURN_STRING(actual, calledFuncName)                                OCTestExecuteFucWithReturn((char *)(actual), __FILE__, (#calledFuncName), __LINE__, OCTEST_DISPLAY_STYLE_UINT32, OCTEST_FUC_RETURN_STRING)
#define OCTEST_FUNC_RETURN_VOID(callFunc, calledFuncName)                                do{ callFunc; OCTestExecuteFucWithReturn(NULL,__FILE__,(#calledFuncName),__LINE__,OCTEST_DISPLAY_STYLE_INT32,OCTEST_FUC_RETURN_VOID);} while(0)

#define OCTEST_EXPECT_TRUE(actual)                                                       OCTestExpectEqualNumber(1, (OCTEST_INT32)(actual), __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_BOOL)
#define OCTEST_EXPECT_FALSE(actual)                                                      OCTestExpectEqualNumber(0, (OCTEST_INT32)(actual), __FILE__, (#actual), OCTEST_MSG_VARIABLE, , __LINE__, OCTEST_DISPLAY_STYLE_BOOL)
#define OCTEST_EXPECT_NOT_NULL(actual)                                                   OCTestExpectEqualNumber(1, (OCTEST_INT32)(actual), __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_NULL)
#define OCTEST_EXPECT_NULL(actual)                                                       OCTestExpectEqualNumber(0, (OCTEST_INT32)(actual), __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_NULL)
#define OCTEST_EXPECT_EQUAL_INT32(expected, actual)                                      OCTestExpectEqualNumber((OCTEST_INT32)(expected), (OCTEST_INT32)(actual), __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_EXPECT_EQUAL_UINT32(expected, actual)                                     OCTestExpectEqualNumber((OCTEST_UINT32)(expected), (OCTEST_UINT32)(actual), __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_EXPECT_NOT_EQUAL_INT32(threshold, actual)                                 OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_NOT_EQUAL, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_EXPECT_NOT_EQUAL_UINT32(threshold, actual)                                OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_NOT_EQUAL, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_EXPECT_GREATER_THAN_INT32(threshold, actual)                              OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_GREATER_THAN, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_EXPECT_GREATER_THAN_UINT32(threshold, actual)                             OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_GREATER_THAN, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_EXPECT_LESS_THAN_INT32(threshold, actual)                                 OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_SMALLER_THAN, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_EXPECT_LESS_THAN_UINT32(threshold, actual)                                OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_SMALLER_THAN, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_EXPECT_GREATER_OR_EQUAL_INT32(threshold, actual)                          OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_GREATER_OR_EQUAL, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_EXPECT_GREATER_OR_EQUAL_UINT32(threshold, actual)                         OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_GREATER_OR_EQUAL, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)
#define OCTEST_EXPECT_LESS_OR_EQUAL_INT32(threshold, actual)                             OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_INT32)(threshold), (OCTEST_INT32)(actual), OCTEST_SMALLER_OR_EQUAL, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_INT32)
#define OCTEST_EXPECT_LESS_OR_EQUAL_UINT32(threshold, actual)                            OCTestExpectGreaterOrLessOrEqualNumber((OCTEST_UINT32)(threshold), (OCTEST_UINT32)(actual), OCTEST_SMALLER_OR_EQUAL, __FILE__, (#actual), OCTEST_MSG_VARIABLE, __LINE__, OCTEST_DISPLAY_STYLE_UINT32)

//测试计数清零，需在测试开始前调用
#define OCTEST_RESET()          OCTestResetTestCnt()
#define OCTEST_RESULT()         OCTestPrintTestCnt()

#endif